import re
from rest_framework.exceptions import ValidationError


def phone_validator(value):
    if not re.match(r"^(1[3|4|5|6|7|8|9])\d{9}$", value):
        raise ValidationError("手机格式错误")


def email_validator(value):
    if not re.match(r'[0-9a-zA-Z.]+@[0-9a-zA-Z.]+?com$', value):
        raise ValidationError("用户邮箱格式错误")
